package com.leaf.u_spring.chapter10;

import org.springframework.context.annotation.Bean;
import org.springframework.jndi.JndiObjectFactoryBean;

/**
 * 
 * jndi装配
 */
public class JNDIConfig {

	/**
	 <jee:jndi-lookup id="dataSource"
	 	jndi-name="/jdbc/SpitterDS"
	 	resource-ref="true"
	 />
	  
	  jndi-name属性用于指定JNDI中资源的名称
	  运行在Java应用服务器中，resource-ref="true"，这样给定的
	  jndi-name将会自动添加"java:comp/env/"前缀
	 
	 */
	@Bean
	public JndiObjectFactoryBean dataSource(){
		JndiObjectFactoryBean jndiObjectFB = new JndiObjectFactoryBean();
		jndiObjectFB.setJndiName("/jdbc/SpitterDS");
		jndiObjectFB.setResourceRef(true);
		jndiObjectFB.setProxyInterface(javax.sql.DataSource.class);
		return jndiObjectFB;
	}
	
	
}
